# coding: utf-8
import logging.config
# import colorlog
from conf import setting_log_module
# from colorama import Fore, Style



# log_colors_config = {
#             'DEBUG': 'yellow',
#             'INFO': 'green',
#             'WARNING': 'yellow',
#             'ERROR': 'red',
#             'CRITICAL': 'red',
#         }

class LoggingUtilsClass:
    def __init__(self):
        logging.config.dictConfig(setting_log_module.LOGGING_DIC)



    def log(self, level, loggername):
        '''
        日志打印函数封装，调用方式  logging_func(level, loggername)(日志信息)
        :param level: 日志等级
        :param loggername: 日志名称
        :return: log : 通过函数的反射机制调用 日志打印函数 logger.debug logger.info等
        '''

        logger = logging.getLogger(loggername)
        # logger = colorlog.getLogger(loggername)
        # 通过函数的反射机制getattr， 返回日志打印级别，如logger.debug
        log = getattr(logger, level)
        return log

logs = LoggingUtilsClass()

if __name__ == '__main__':
    logs.log('debug', '测试日志')('11111')
    # LoggingUtilsClass().logging_func('error', '选择输出响应结果的类型')(f'响应结果不支持json类型')
